package com.cloud.lan.api.manage;

import com.cloud.lan.api.dto.req.BaseReq;
import com.cloud.lan.api.dto.req.LanActivityReq;
import com.cloud.lan.entity.base.BaseResponse;
import com.cloud.lan.service.ILanActivityCodeService;
import com.cloud.lan.service.ILanActivityService;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * 兑换券入口
 * @author ErKang
 * @date Created in 2021/12/5 04:24
 * @title TestApi.java
 * Department: Product development
 */
@RestController
@RequestMapping(value = {"/v1/manage/activity/"}, method = {RequestMethod.GET, RequestMethod.POST}, produces = {"application/json"})
public class LanActivityManageApi {

    @Resource
    ILanActivityService lanActivityService;

    @Resource
    ILanActivityCodeService lanActivityCodeService;

    @RequestMapping("manageList")
    public BaseResponse<Object> manageList(LanActivityReq req) {
        return lanActivityService.manageList(req);
    }

    @RequestMapping("add")
    public BaseResponse<Object> add(@RequestBody LanActivityReq req) {
        return lanActivityService.add(req);
    }

    @RequestMapping("update")
    public BaseResponse<Object> update(@RequestBody LanActivityReq req) {
        return lanActivityService.update(req);
    }

    @RequestMapping("importActivityCode")
    public BaseResponse<Object> importActivityCode(@RequestHeader(BaseReq.ut) String token, @RequestParam("file") MultipartFile file
            , @RequestParam("jsonCode") String jsonCode, @RequestParam("activityId") Long activityId) {
        return lanActivityCodeService.importActivityCode(token, file, jsonCode, activityId);
    }
}
